/**
 * C++ Call Graph (Direct Calls)
 *
 * 输出列：
 *  - caller_qualified: 调用者函数的限定名（含命名空间/类）
 *  - caller_file: 调用者定义文件
 *  - callee_qualified: 被调用者函数的限定名
 *  - callee_file: 被调用者定义文件
 *  - call_file: 调用发生的文件
 *  - call_line: 调用发生的行号
 */

import cpp

/** 获取函数的限定名 */
string getQualifiedName(Function f) {
  result = f.getQualifiedName()
}

from Function caller, Function callee, Call c
where
  c.getEnclosingFunction() = caller and
  c.getTarget() = callee
select
  getQualifiedName(caller) as caller_qualified,
  caller.getFile().getRelativePath() as caller_file,
  getQualifiedName(callee) as callee_qualified,
  callee.getFile().getRelativePath() as callee_file,
  c.getFile().getRelativePath() as call_file,
  c.getLocation().getStartLine() as call_line

